$(function () {
    $("#client_datagrid").datagrid({
        fit: true,
        url: "/clientTransfer/list",
        fitColumns: true,
        striped: true,
        toolbar: "#btn",
        pagination: true,
        singleSelect: true,
        checkOnSelect: true,
        rownumbers: true,
        columns: [[
            {field: 'id', title: '编号', hidden: true},
            {field: 'checkbox', checkbox: true, tilte: '选中', width: 100},
            {field: 'transdate', title: '移交时间', align: 'center', width: 100},
            {
                field: 'operator',
                title: '移交操作人',
                align: 'center',
                width: 100,
                formatter: function (value, row, index) {
                    return value ? "<p>"+value.username+"</p>" : "<p>有bug</p>"
                }
            },
            {
                field: 'client', title: '客户', align: 'center', width: 100, formatter: function (value, row, index) {
                return value ? value.clientname : "有bug"
            }
            },
            {
                field: 'oldprincipal',
                title: '原负责人',
                align: 'center',
                width: 100,
                formatter: function (value, row, index) {
                    return value ? value.username : "有bug"
                }
            },
            {
                field: 'newprincipal',
                title: '现负责人',
                align: 'center',
                width: 100,
                formatter: function (value, row, index) {
                    return value ? value.username : "有bug"
                }
            },
            {field: 'transreason', title: '移交原因', align: 'center', width: 100}
        ]]
    })
})
//高级查询
function query() {
    var beginDate = $("#beginDate").datebox("getValue");
    var endingDate = $("#endingDate").datebox("getValue");
    var operatorName = $("#operatorName").textbox("getValue");
    var newPrincipalName = $("#newPrincipalName").textbox("getValue");
    var clientName = $("#clientName").textbox("getValue");
    var oldPrincipalName = $("#oldPrincipalName").textbox("getValue");
    $("#client_datagrid").datagrid("load", {
        beginDate: beginDate,
        endingDate: endingDate,
        operatorName: operatorName,
        newPrincipalName: newPrincipalName,
        oldPrincipalName: oldPrincipalName,
        clientName: clientName
    })
    $('#client_datagrid').datagrid('loadData', { total: 0, rows: [] });
}
//刷新
function reflush() {
    $("#beginDate").datebox("reset");
    $("#endingDate").datebox("reset");
    $("#operatorName").textbox("reset");
    $("#newPrincipalName").textbox("reset");
    $("#clientName").textbox("reset");
    $("#oldPrincipalName").textbox("reset");
    $("#client_datagrid").datagrid("load", {
        beginDate: null,
        endingDate: null,
        operatorName: null,
        newPrincipalName: null,
        oldPrincipalName: null,
        clientName: null
    })

}